package com.example.lzwphoto.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @Desc: TODO
 * @Author: LvKun
 * @Date: 2024-02-07
 * @Version: 1.0
 */

@Configuration
public class WebMvcCross implements WebMvcConfigurer {


    @Override
    public void addCorsMappings(CorsRegistry registry) {
        registry.addMapping("/**")// 拦截所有的请求
                .allowedOrigins("*")// 可跨域的域名，*为所有
                .allowCredentials(true)
                .allowedMethods("GET", "POST", "PUT", "DELETE", "OPTIONS")// 允许跨域的方法，可以单独配置
                .maxAge(3600);
    }

}
